package com.foocus.foocuscloud.common.aop.db;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 数据源切换
 */
public class DataSourceContext {
    private static final Logger LOGGER = LoggerFactory.getLogger(DataSourceContext.class);

    private static final ThreadLocal<String> local = new ThreadLocal<>();

    public static void changeDBType(String dbType) {

        local.set(dbType);
        LOGGER.info("切换数据源：{}", dbType);
    }

    public static String getDBType() {

        return local.get();
    }

    public static void removeDBType() {

        local.remove();
    }

}
